<?php


abstract class BaseUserExtra extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $user_id;


	
	protected $fullname;


	
	protected $gender;


	
	protected $email;


	
	protected $website;


	
	protected $ringtone_id;


	
	protected $description;


	
	protected $remark;


	
	protected $province_id;


	
	protected $country_id;


	
	protected $checknum;


	
	protected $first_register;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getUserId()
	{

		return $this->user_id;
	}

	
	public function getFullname()
	{

		return $this->fullname;
	}

	
	public function getGender()
	{

		return $this->gender;
	}

	
	public function getEmail()
	{

		return $this->email;
	}

	
	public function getWebsite()
	{

		return $this->website;
	}

	
	public function getRingtoneId()
	{

		return $this->ringtone_id;
	}

	
	public function getDescription()
	{

		return $this->description;
	}

	
	public function getRemark()
	{

		return $this->remark;
	}

	
	public function getProvinceId()
	{

		return $this->province_id;
	}

	
	public function getCountryId()
	{

		return $this->country_id;
	}

	
	public function getChecknum()
	{

		return $this->checknum;
	}

	
	public function getFirstRegister()
	{

		return $this->first_register;
	}

	
	public function setUserId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->user_id !== $v) {
			$this->user_id = $v;
			$this->modifiedColumns[] = UserExtraPeer::USER_ID;
		}

	} 
	
	public function setFullname($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->fullname !== $v) {
			$this->fullname = $v;
			$this->modifiedColumns[] = UserExtraPeer::FULLNAME;
		}

	} 
	
	public function setGender($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->gender !== $v) {
			$this->gender = $v;
			$this->modifiedColumns[] = UserExtraPeer::GENDER;
		}

	} 
	
	public function setEmail($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = UserExtraPeer::EMAIL;
		}

	} 
	
	public function setWebsite($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->website !== $v) {
			$this->website = $v;
			$this->modifiedColumns[] = UserExtraPeer::WEBSITE;
		}

	} 
	
	public function setRingtoneId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ringtone_id !== $v) {
			$this->ringtone_id = $v;
			$this->modifiedColumns[] = UserExtraPeer::RINGTONE_ID;
		}

	} 
	
	public function setDescription($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->description !== $v) {
			$this->description = $v;
			$this->modifiedColumns[] = UserExtraPeer::DESCRIPTION;
		}

	} 
	
	public function setRemark($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->remark !== $v) {
			$this->remark = $v;
			$this->modifiedColumns[] = UserExtraPeer::REMARK;
		}

	} 
	
	public function setProvinceId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->province_id !== $v) {
			$this->province_id = $v;
			$this->modifiedColumns[] = UserExtraPeer::PROVINCE_ID;
		}

	} 
	
	public function setCountryId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->country_id !== $v) {
			$this->country_id = $v;
			$this->modifiedColumns[] = UserExtraPeer::COUNTRY_ID;
		}

	} 
	
	public function setChecknum($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->checknum !== $v) {
			$this->checknum = $v;
			$this->modifiedColumns[] = UserExtraPeer::CHECKNUM;
		}

	} 
	
	public function setFirstRegister($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->first_register !== $v) {
			$this->first_register = $v;
			$this->modifiedColumns[] = UserExtraPeer::FIRST_REGISTER;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->user_id = $rs->getInt($startcol + 0);

			$this->fullname = $rs->getString($startcol + 1);

			$this->gender = $rs->getInt($startcol + 2);

			$this->email = $rs->getString($startcol + 3);

			$this->website = $rs->getString($startcol + 4);

			$this->ringtone_id = $rs->getInt($startcol + 5);

			$this->description = $rs->getString($startcol + 6);

			$this->remark = $rs->getString($startcol + 7);

			$this->province_id = $rs->getInt($startcol + 8);

			$this->country_id = $rs->getInt($startcol + 9);

			$this->checknum = $rs->getString($startcol + 10);

			$this->first_register = $rs->getInt($startcol + 11);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 12; 
		} catch (Exception $e) {
			throw new PropelException("Error populating UserExtra object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UserExtraPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			UserExtraPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UserExtraPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = UserExtraPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += UserExtraPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = UserExtraPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UserExtraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getUserId();
				break;
			case 1:
				return $this->getFullname();
				break;
			case 2:
				return $this->getGender();
				break;
			case 3:
				return $this->getEmail();
				break;
			case 4:
				return $this->getWebsite();
				break;
			case 5:
				return $this->getRingtoneId();
				break;
			case 6:
				return $this->getDescription();
				break;
			case 7:
				return $this->getRemark();
				break;
			case 8:
				return $this->getProvinceId();
				break;
			case 9:
				return $this->getCountryId();
				break;
			case 10:
				return $this->getChecknum();
				break;
			case 11:
				return $this->getFirstRegister();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = UserExtraPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getUserId(),
			$keys[1] => $this->getFullname(),
			$keys[2] => $this->getGender(),
			$keys[3] => $this->getEmail(),
			$keys[4] => $this->getWebsite(),
			$keys[5] => $this->getRingtoneId(),
			$keys[6] => $this->getDescription(),
			$keys[7] => $this->getRemark(),
			$keys[8] => $this->getProvinceId(),
			$keys[9] => $this->getCountryId(),
			$keys[10] => $this->getChecknum(),
			$keys[11] => $this->getFirstRegister(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UserExtraPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setUserId($value);
				break;
			case 1:
				$this->setFullname($value);
				break;
			case 2:
				$this->setGender($value);
				break;
			case 3:
				$this->setEmail($value);
				break;
			case 4:
				$this->setWebsite($value);
				break;
			case 5:
				$this->setRingtoneId($value);
				break;
			case 6:
				$this->setDescription($value);
				break;
			case 7:
				$this->setRemark($value);
				break;
			case 8:
				$this->setProvinceId($value);
				break;
			case 9:
				$this->setCountryId($value);
				break;
			case 10:
				$this->setChecknum($value);
				break;
			case 11:
				$this->setFirstRegister($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = UserExtraPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setFullname($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setGender($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setEmail($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setWebsite($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setRingtoneId($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setDescription($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setRemark($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setProvinceId($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setCountryId($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setChecknum($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setFirstRegister($arr[$keys[11]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(UserExtraPeer::DATABASE_NAME);

		if ($this->isColumnModified(UserExtraPeer::USER_ID)) $criteria->add(UserExtraPeer::USER_ID, $this->user_id);
		if ($this->isColumnModified(UserExtraPeer::FULLNAME)) $criteria->add(UserExtraPeer::FULLNAME, $this->fullname);
		if ($this->isColumnModified(UserExtraPeer::GENDER)) $criteria->add(UserExtraPeer::GENDER, $this->gender);
		if ($this->isColumnModified(UserExtraPeer::EMAIL)) $criteria->add(UserExtraPeer::EMAIL, $this->email);
		if ($this->isColumnModified(UserExtraPeer::WEBSITE)) $criteria->add(UserExtraPeer::WEBSITE, $this->website);
		if ($this->isColumnModified(UserExtraPeer::RINGTONE_ID)) $criteria->add(UserExtraPeer::RINGTONE_ID, $this->ringtone_id);
		if ($this->isColumnModified(UserExtraPeer::DESCRIPTION)) $criteria->add(UserExtraPeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(UserExtraPeer::REMARK)) $criteria->add(UserExtraPeer::REMARK, $this->remark);
		if ($this->isColumnModified(UserExtraPeer::PROVINCE_ID)) $criteria->add(UserExtraPeer::PROVINCE_ID, $this->province_id);
		if ($this->isColumnModified(UserExtraPeer::COUNTRY_ID)) $criteria->add(UserExtraPeer::COUNTRY_ID, $this->country_id);
		if ($this->isColumnModified(UserExtraPeer::CHECKNUM)) $criteria->add(UserExtraPeer::CHECKNUM, $this->checknum);
		if ($this->isColumnModified(UserExtraPeer::FIRST_REGISTER)) $criteria->add(UserExtraPeer::FIRST_REGISTER, $this->first_register);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(UserExtraPeer::DATABASE_NAME);

		$criteria->add(UserExtraPeer::USER_ID, $this->user_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getUserId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setUserId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setFullname($this->fullname);

		$copyObj->setGender($this->gender);

		$copyObj->setEmail($this->email);

		$copyObj->setWebsite($this->website);

		$copyObj->setRingtoneId($this->ringtone_id);

		$copyObj->setDescription($this->description);

		$copyObj->setRemark($this->remark);

		$copyObj->setProvinceId($this->province_id);

		$copyObj->setCountryId($this->country_id);

		$copyObj->setChecknum($this->checknum);

		$copyObj->setFirstRegister($this->first_register);


		$copyObj->setNew(true);

		$copyObj->setUserId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new UserExtraPeer();
		}
		return self::$peer;
	}

} 